package com.mk.domain;

import com.github.d925529.apidoc.annotation.ApiField;
import org.beetl.sql.core.annotatoin.AssignID;
import org.beetl.sql.core.annotatoin.Param;
import org.beetl.sql.core.annotatoin.Table;
import org.beetl.sql.core.mapper.BaseMapper;

import javax.persistence.Transient;
import java.io.Serializable;
import java.util.List;

@Table(name = "cp_ssorole")
@SuppressWarnings("unused")
public class CpSsorole implements Serializable {
    @AssignID
    //角色ID
    @ApiField("角色ID")
    private String roleid;

    //角色名字
    @ApiField("角色名字")
    private String rolename;

    //角色编码
    @ApiField("角色编码")
    private String rolecode;

    //备注
    @ApiField("备注")
    private String remark;

    //角色ID
    @ApiField("角色父id")
    private String rolepid;
    @Transient
    private String rolepname;

    @Transient
    private List<CpSsorole> list;

    /**
     * @return 角色ID
     */
    public String getRoleid() {
        return roleid;
    }

    /**
     * @param roleid 角色ID
     */
    public void setRoleid(String roleid) {
        this.roleid = roleid;
    }

    /**
     * @return 角色名字
     */
    public String getRolename() {
        return rolename;
    }

    /**
     * @param rolename 角色名字
     */
    public void setRolename(String rolename) {
        this.rolename = rolename;
    }

    /**
     * @return 角色编码
     */
    public String getRolecode() {
        return rolecode;
    }

    /**
     * @param rolecode 角色编码
     */
    public void setRolecode(String rolecode) {
        this.rolecode = rolecode;
    }

    /**
     * @return 备注
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @param remark 备注
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getRolepid() {
        return rolepid;
    }

    public void setRolepid(String rolepid) {
        this.rolepid = rolepid;
    }

    public String getRolepname() {
        return rolepname;
    }

    public void setRolepname(String rolepname) {
        this.rolepname = rolepname;
    }

    public List<CpSsorole> getList() {
        return list;
    }

    public void setList(List<CpSsorole> list) {
        this.list = list;
    }

    public interface Mapper extends BaseMapper<CpSsorole> {
        public List<CpSsorole> getRolesByUser(@Param("userid") String userid);

        /**
         * 平台
         * 根据角色id删除对应的角色
         *
         * @param roleid
         * @return
         */
        int deleteRole(@Param("roleid") String roleid);

        /**
         * 平台
         * 保存平台角色层级结构
         *
         * @param roles
         * @return
         */
        int saveRoleStructure(@Param("roles") List<CpSsorole> roles);

        /**
         * 保存平台角色分配的资源
         *
         * @param roleid
         * @param resourceidList
         * @return
         */
        int saveRoleResource(@Param("roleid") String roleid, @Param("resourceidList") List<String> resourceidList);

        List<CpSsorole> selectAll();

        CpSsorole selectByRoleid(@Param("roleid") String roleid);
    }
}